package com.jackeys.piaems.util;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName: FileUtil
 * @Description: 文件上传工具类
 * @Author: Jackeys
 * @Date: 2021-06-22 15:51
 * @Version: 1.0
 */
public class FileUtil {
    public static boolean upload(String directoryPath, MultipartFile file,String filename){
        File directory = new File(directoryPath);
        if (!directory.exists()) {
            directory.mkdirs();
        }
        try {
            file.transferTo(new File(directoryPath+filename));
        }catch (IOException e){
            e.printStackTrace();
            return false;
        }
        return true;
    }
}
